package com.example.util;

public class DecodeUtil {
	/**
	 * 把bcd码转化为字符串
	 * 
	 * @param bcd
	 * @return
	 */
	public static String BCDDecode(long bcd) {
		int offset;
		char[] cs = new char[16];
		for (int i = 0; i < 16; i++) {
			offset = 64 - (15 - i) * 4;
			cs[i] = (char) ((bcd >>> offset) & 0xf);
			cs[i] += 48;
		}

		return new String(cs);
	};

	public static String BCDDecode(char[] bs) {

		return null;

	}

	public static int byteToInt(byte[] bytes) {
		int num = 0;
		int j = 0;
		int length = Math.min(4, bytes.length);
		for (int i = 0; i < length; i++) {
			j = bytes[i];
			j <<= ((length - i - 1) * 8);
			num += j;
		}
		return num;

	}


}
